package com.example.controller;

import com.example.entity.AccountInfo;
import com.example.response.R;
import com.example.service.AccountInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private AccountInfoService accountInfoService;

    //登录
    @PostMapping("/login")
    public R<Map<String,String>> accountLogin(@RequestBody AccountInfo accountInfo){
        System.out.println(accountInfo);
        //登录
        return accountInfoService.login(accountInfo);
    }

    /**
     * 查询所有用户的信息
     * @return
     */
    @PostMapping("/page")
    @PreAuthorize("hasAnyAuthority('test')")
    public R queryAccount(){
        return accountInfoService.queryAccount();
    }

}
